<template>
  <view :style="themeColor">
    <view class="page">
      <!---flex布局flex布局开始-->
      <view class="flex flex-wrap align-center justify-center benben-flex-layout registerLogin_flex_0">
        <image class='registerLogin_fd0_0' mode="aspectFit" :src='STATIC_URL+"19.png"'></image>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center registerLogin_flex_1">
        <view>
          <benben-flex-tabs class-name='registerLogin_benbenTabsfd1_0' v-model="tabls" ref="benben_tabsfd1_0"
            select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false' :open-sticky='true' :top='0'
            :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0">

            <scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
              class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd1_0.moveX"
              scroll-with-animation="all .3s ease">
              <view class="benben-tabs-content" id="benben_tabsfd1_0-content">
                <view id="benben_tabsfd1_0-title" class="benben-tabs-title flex align-center flex ">
                  <!-- <view
                    :class="{ 'checkTitlefd1_0': tabls == '1', 'flex flex-wrap align-center registerLogin_titlefd1_0_c3': true }"
                    @tap="tabls = '1'" :id="`benben_tabsfd1_0-title-item-${'1'}`">

                    <text>{{$t('手机号注册')}}</text>

                  </view> -->
                  <view
                    :class="{ 'checkTitlefd1_0': tabls == '2', 'flex flex-wrap align-center registerLogin_titlefd1_0_c4': true }"
                    @tap="tabls = '2'" :id="`benben_tabsfd1_0-title-item-${'2'}`">

                    <text>{{$t('邮箱号注册')}}</text>

                  </view>
                </view>
                <view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
                  id="benben_tabsfd1_0-line"
                  class="benben-tabs-line flex benben-flex-tabs-line registerLogin_linefd1_0"></view>
              </view>
            </scroll-view>

          </benben-flex-tabs>

        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout registerLogin_flex_2">
        <view class='flex flex-wrap align-center registerLogin_fd2_0' v-if=" tabls=='1'">
          <image class='registerLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"64.png"'></image>
          <view class='flex flex-wrap align-center codeLogin_fd1_3_c1' @click.stop="pickerDiy1704874099380=true">
            <text class='codeLogin_fd1_3_c1_c0'>+{{area_code}}</text>
            <!-- <image class='codeLogin_fd1_3_c1_c1' mode="aspectFit" :src='STATIC_URL+"64.png"'></image> -->
          </view>
          <input class='flex-sub registerLogin_fd2_0_c1' type="number" :placeholder="$t('请输入手机号')" confirm-type="done"
            :maxlength="20" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx"
            v-model="dataObj.actount" />
        </view>
        <view class='flex flex-wrap align-center registerLogin_fd2_0' v-if=" tabls=='2'">
          <image class='registerLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"185.png"'></image>
          <input class='flex-sub registerLogin_fd2_0_c1' type="text" :placeholder="$t('请输入邮箱号')" confirm-type="done"
            :maxlength="-1" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" v-model="dataObj.mail" />
        </view>
        <view class='flex flex-wrap align-center registerLogin_fd2_0'>
          <image class='registerLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"78.png"'></image>
          <input class='flex-sub registerLogin_fd2_0_c1' type="number" :placeholder="$t('请输入验证码')" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" v-model="code" />
          <benben-send-verification-code ref="vCode1702821973229" class='registerLogin_fd2_2_c2'
            :after-text="$t('后重新获取')" :before-text="$t('获取验证码')" :emptye-text="$t('请输入账号')"
            :validate-text="$t('请输入正确的账号')" account-type='phone' :auto='true' type='1' :phone="dataObj.actount"
            :areacode="area_code" v-if=" tabls=='1'"></benben-send-verification-code>
          <benben-send-verification-code ref="vCode1703403575996" class='registerLogin_fd2_2_c2'
            :after-text="$t('后重新获取')" :before-text="$t('获取验证码')" :emptye-text="$t('请输入邮箱号')"
            :validate-text="$t('请输入正确邮箱号')" account-type='email' :auto='true' type='1' :phone="dataObj.mail"
            v-if=" tabls=='2'"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center registerLogin_fd2_0'>
          <image class='registerLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"65.png"'></image>
          <benben-flex-password-diy v-model="dataObj.paswarld"
            class-name="flex flex align-center registerLogin_fd2_3_c1" :placeholder="$t('请输入密码(6~12位字母+数字)')"
            :maxlength="12" :default-type='true' placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx">
            <template #show>
              <text class='fu-iconfont2  registerLogin_fd2_3_c1_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  registerLogin_fd2_3_c1_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
        <view class='flex flex-wrap align-center justify-center registerLogin_fd2_4'>
          <button class='registerLogin_fd2_4_c0' @tap.stop="validationRegistrationFunc()">{{$t('注册')}}</button>
        </view>
        <view class='flex flex-wrap align-center justify-center registerLogin_fd2_5' @tap.stop="handleJumpDiy"
          data-type="navigateTo" :data-url="`/pages/tabBar/loginPage/loginPage`">
          <text class='registerLogin_fd2_5_c0'>{{$t('已有账号，前去')}}</text>
          <text class='registerLogin_fd2_5_c1'>{{$t('登录')}}</text>
        </view>
        <!-- <view class="text-sm text-weight-600 margin-top-sm  gohome" @tap.stop="handleJumpDiy" data-type="switchTab"
          :data-url="`/pages/tabBar/homePage/homePage`">去主页</view> -->
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex registerLogin_flex_3">
        <view class='flex flex-direction flex-wrap align-stretch flex-sub'>
          <view class='flex flex-wrap align-center justify-center registerLogin_fd3_0_c0'>
            <benben-flex-switch-new class-name='flex flex registerLogin_fd3_0_c0_c0' v-model="dataObj.is_tick"
              :disabled='false' :auto='true'>
              <template v-slot:checked>

                <view class='flex flex position-relative align-center'>
                  <image class='registerLogin_checkfd3_0_c0_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"15.png"'>
                  </image>
                </view>

              </template>
              <template v-slot:unchecked>

                <view class='flex flex position-relative justify-end align-center'>
                  <image class='registerLogin_noCheckfd3_0_c0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"96.png"'>
                  </image>
                </view>

              </template>
            </benben-flex-switch-new>
            <text class='registerLogin_fd3_0_c0_c1'>{{$t('勾选即默认同意')}}</text>
            <text class='registerLogin_fd3_0_c0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
              :data-url="`/pages/dlzc/agreements/agreements`">{{$t('《用户注册协议》')}}</text>
            <text class='registerLogin_fd3_0_c0_c1'>{{$t('与')}}</text>
            <text class='registerLogin_fd3_0_c0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
              :data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">{{$t('《隐私政策》')}}</text>
          </view>
        </view>

      </view>
      <view :style="{height: '253rpx'}"></view>
      <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1704874099380" :value.sync='area_code'
        :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='name'
        :default-props='{"label":"name","value":"name"}'>
        <template #picker-header>
          <view class='flex flex-wrap align-center justify-between myProfile_picker2_0'>
            <text class='myProfile_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
            <text>选择区号</text>
            <text class='myProfile_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
          </view>
        </template>
      </benben-picker>

    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "fd2_3_c1": "",
        "tabsInfofd1_0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        "tabls": "2",
        "dataObj": {
          "actount": "",
          "mail": "",
          "paswarld": "",
          "is_tick": false
        },
        "code": "",
        "data": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": ""
          }
        },
        areaList: [],
        area_code: '',
        pickerDiy1704874099380: false,
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.$api.post(global.apiUrls.post66178b95a1d2b).then(res => {
        if (res.data.code == 1) {
          this.areaList = res.data.data
          this.area_code = this.areaList[0].name
        }
      })
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //效验注册
      async validationRegistrationFunc() {
        if (this.tabls == '1') {
          if (!validate(this.dataObj.actount, 'require')) {
            this.$message.info(global.i18n.t('手机号不能为空'));
            return false;
          }
          // if (!validate(this.dataObj.actount, 'phone')) {
          //   this.$message.info(global.i18n.t('请输入正确的手机号'));
          //   return false;
          // }
          this.dataObj.mail = ''
        } else if (this.tabls != '1') {
          if (!validate(this.dataObj.mail, 'require')) {
            this.$message.info(global.i18n.t('邮箱号不能为空'));
            return false;
          }
          if (!validate(this.dataObj.mail, 'email')) {
            this.$message.info(global.i18n.t('请输入正确的邮箱号,提示：不要有空格以及特殊符号'));
            return false;
          }
          this.dataObj.actount = ''
        }
        if (!validate(this.code, 'require')) {
          this.$message.info(global.i18n.t('验证码不能为空'));
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info(global.i18n.t('请输入正确的验证码'));
          return false;
        }
        if (!validate(this.dataObj.paswarld, 'require')) {
          this.$message.info(global.i18n.t('密码不能为空'));
          return false;
        }
        if (!validate(this.dataObj.paswarld, 'password')) {
          this.$message.info(global.i18n.t('请输入密码(6~12位字母+数字)'));
          return false;
        }
        if (this.dataObj.is_tick === false) {
          uni.showToast({
            title: '请勾选用户协议',
            icon: 'none',
            // position: 'bottom',
            duration: 3000,
          })
          return false;
        }
        //请求方法
        //数据验证

        let datadata = await this.$api.post(global.apiUrls.post5cad9f63e4f94, {
          mobile: this.dataObj.actount,
          code: this.code,
          type: '1',
          password: this.dataObj.paswarld,
          email: this.dataObj.mail,
          mobile_code: this.area_code
        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data

        this.$store.commit('saveToken', this.data.userinfo.user_token)
        this.$store.commit('updateUserInfo', this.data.userinfo)
        // this.toHomeDiy();
        uni.redirectTo({
          url: `/pages/dlzc/chooseType/chooseType`
        })
      }
    }
  };
</script>
<style lang="scss" scoped>
  .gohome {
    text-align: center;
    color: #912F22;
  }

  .codeLogin_fd1_3_c1_c1 {
    width: 14rpx;
    height: 8rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd1_3_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .codeLogin_fd1_3_c1 {
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .myProfile_picker2_0_c2 {
    color: rgba(100, 80, 235, 1);
  }

  .myProfile_picker2_0_c0 {
    color: var(--benbenFontColor2);
  }

  .myProfile_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #FFFFFF;
    background-size: 100% auto;
  }

  .registerLogin_flex_0 {
    padding: 105rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_fd0_0 {
    width: 136rpx;
    height: 141rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_flex_1 {
    margin: 87rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_titlefd1_0_c4 {
    margin: 0rpx 0rpx 0rpx 48rpx;
  }

  .registerLogin_titlefd1_0_c3 {
    margin: 0rpx 0rpx 0rpx 64rpx;
  }

  .registerLogin_linefd1_0 {
    background: #3A87F9;
    width: 120rpx;
    height: 8rpx;
    top: 80rpx;
    background-size: 100% auto !important;
    border-radius: 44rpx;
  }

  .checkTitlefd1_0 {
    font-weight: 700 !important;
    font-size: 28rpx !important;
    color: #3A87F9 !important;
  }

  ::v-deep .registerLogin_benbenTabsfd1_0 {
    width: 750rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    font-size: 28rpx;
    font-weight: 500;
    color: #666666;
  }

  .registerLogin_flex_2 {
    padding: 0rpx 64rpx 0rpx 64rpx;
    margin: 55rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_fd2_5_c1 {
    color: #4177DD;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .registerLogin_fd2_5_c0 {
    color: rgba(102, 102, 102, 1);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .registerLogin_fd2_5 {
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_fd2_4_c0 {
    background: #3A87F9;
    border-radius: 44rpx;
    width: 616rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .registerLogin_fd2_4 {
    margin: 80rpx 0rpx 0rpx 0rpx;
  }

  .registerLogin_fd2_3_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .registerLogin_fd2_3_c1_icon1 {
    text-align: center;
    font-size: 40rpx;
  }

  ::v-deep .registerLogin_fd2_3_c1 {
    width: 543rpx;
    font-size: 28rpx;
    height: 32rpx;
    color: #333;
  }

  .registerLogin_fd2_2_c2 {
    line-height: 42rpx;
    text-align: center;
    font-size: 27rpx;
    color: #3A87F9;
  }

  .registerLogin_fd2_0_c1 {
    font-size: 28rpx;
    color: #333;
  }

  .registerLogin_fd2_0_c0 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .registerLogin_fd2_0 {
    border-bottom: 1px solid rgba(232, 229, 216, 1);
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .registerLogin_flex_3 {
    width: 750rpx;
    height: 253rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(42rpx + var(--window-bottom));
  }

  .registerLogin_fd3_0_c0_c2 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 800;
    line-height: 32rpx;
  }

  .registerLogin_fd3_0_c0_c1 {
    color: rgba(153, 153, 153, 1);
    font-size: 28rpx;
    font-weight: 800;
    line-height: 32rpx;
  }

  .registerLogin_noCheckfd3_0_c0_c0_c1_c0 {
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 40rpx;
    height: 40rpx;
  }

  .registerLogin_checkfd3_0_c0_c0_c0_c0 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
  }

  ::v-deep .registerLogin_fd3_0_c0_c0 {
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .registerLogin_fd3_0_c0 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }
</style>
